package com.cplsys.iacna.ws.skeleton;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.cplsys.iacna.domain.Bascula;
import com.cplsys.iacna.domain.Formula;
import com.cplsys.iacna.domain.Ingrediente;
import com.cplsys.iacna.hibernate.utils.HibernateUtil;
import com.cplsys.iacna.ws.skeleton.iface.IACNAIface;

public class WSiacna implements IACNAIface {
	private Transaction transaction;
	private SessionFactory sessionFactory;
	
	public WSiacna() {
		Bascula basc = getBascula(2);
		System.err.println(basc.getDescripcion() + " : " + basc.getUnidadMedida());
	}

	@Override
	public Bascula getBascula(int bascula) {
		List<Bascula> basculas = 
				HibernateUtil.getSessionFactory().openSession().createQuery(
				"from Bascula as b where b.nombre = ?").setString(
				0, String.valueOf(bascula)) .list();
		return basculas != null && !basculas.isEmpty() ? basculas.get(0) : null;
	}

	@Override
	public void habilitarBascula(int bascula) {
		
	}

	@Override
	public void deshabilitarBascula(int bascula) {
	
	}

	@Override
	public int getTotalIngredientesFormula() {
		return 0;
	}

	@Override
	public Formula getFormula() {
		return null;
	}

	@Override
	public void saveRegistroProduccion(Formula formula) {
	
	}

	@Override
	public Ingrediente getIngrediente(int ingrediente, boolean success) {
		return null;
	}

}
